"""
新增任务页面
"""
import ddt
from selenium.webdriver.common.by import By
from pages.base_page import BasePage
from tools.tools import Tada


class RwAddHomePage(BasePage):
    url='/crm/index.php?m=task&a=add'
    #定位器
    title_locator = (By.ID, 'subject')
    content_locator = (By.XPATH, '/html/body/div[5]/div[2]/div/form/table/tbody/tr[7]/td[2]/div/div[2]/iframe')
    task_add_btn_locator = (By.XPATH, '/html/body/div[5]/div[2]/div/form/table/tfoot/tr/td[2]/input[1]')
    owner_name_locator = (By.ID, 'owner_name')
    owner_ok_locator = (By.CSS_SELECTOR,'body > div:nth-child(12) > div.ui-dialog-buttonpane.ui-widget-content.ui-helper-clearfix > div > button:nth-child(1)')
    relate_locator = (By.ID, 'about_roles_name')
    relate_one_locator = (By.XPATH, '//*[@id="ta1"]/span[1]/input')
    relate_btn_ok_locator = (By.XPATH, '/html/body/div[8]/div[3]/div/button[1]')
    relate_last_locator = (By.XPATH, '//*[@id="ta1"]/span[2]/input')
    #断言
    add_renwu_success_locator=(By.CSS_SELECTOR,'body > div.container > div.alert.alert-success')

    #输入标题
    def input_title(self,title):
       self.driver.find_element(*self.title_locator).send_keys(title)
    #选择负责人
    def owner_name(self):
       self.driver.find_element(*self.owner_name_locator).click()
    #负责人弹窗OK按钮
    def owner_ok(self):
       self.driver.find_element(*self.owner_ok_locator).click()
    #输入任务内容
    def input_content(self,content):
       self.driver.find_element(*self.content_locator).send_keys(content)
    #保存任务
    def add_task(self):
       self.driver.find_element(*self.task_add_btn_locator).click()
    #点击任务相关人
    def relate_click(self):
       self.driver.find_element(*self.relate_locator).click()
    #选择弹窗第一个
    def relate_one(self):
       self.driver.find_element(*self.relate_one_locator).click()
    #选择弹窗最后一个
    def relate_last(self):
        self.driver.find_element(*self.relate_last_locator).click()
    #弹窗OK按钮
    def relat_ok(self):
       self.driver.find_element(*self.relate_btn_ok_locator).click()

    #获取添加成功的断言文本
    def duanyan_renwu(self):
        return self.driver.find_element(*self.add_renwu_success_locator).text











